// http project main.go
package main

import (
	"3rd/utils"
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	fmt.Println("Hello World!")
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		defer r.Body.Close()
		b, err := ioutil.ReadAll(r.Body)
		if err != nil {
			fmt.Println(err)
			return
		}
		var sn string
		if err := utils.ParseBodyAndValidate(b, &struct {
			Sn *string `json:"sn" valid:"Required"`
		}{&sn}); err != nil {
			fmt.Println("---------------------->", err)
			return
		}

		fmt.Println("-------->", sn)
	})

	http.ListenAndServe(":7777", nil)
}
